<template>
  <div class="rights">
    <el-card>
      <el-table :data="rightsForm" border style="width: 100%; margin: 10px 0">
        <!-- max-height="700px" -->
        <el-table-column label="#" type="index"> </el-table-column>
        <el-table-column prop="authName" label="权限名称"> </el-table-column>
        <el-table-column prop="path" label="路径"> </el-table-column>
        <el-table-column label="权限等级">
          <template slot-scope="scope">
            <el-tag
              :type="
                scope.row.level == 1
                  ? ''
                  : scope.row.level == 2
                  ? 'success'
                  : 'warning'
              "
              >{{ scope.row.level | filLevel }}</el-tag
            >
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>
<script>
import { getRights } from "@/api/index";
export default {
  data() {
    return {
      rightsForm: [],
    };
  },
  created() {
    this.getRightsData();
  },
  methods: {
    async getRightsData() {
      let {
        data,
        meta: { msg, status },
      } = await getRights({ type: "list" });
      if (status != 200) return this.$message.warning(msg);
      this.rightsForm = data;
    },
  },
  filters: {
    filLevel(level) {
      if (level == 0) return "一级";
      if (level == 2) return "二级";
      return "三级";
    },
  },
};
</script>